// pages/agent/card.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:{uname:'',list:[],card:''},
    sub:{bank:'',bankTip:'',card:''},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.load();
  },
  setInput(e){
    let key=e.currentTarget.dataset.key;
    this.setData({
      [key]:e.detail
    })
  },
  pickerBank(e){
    this.setData({
      'sub.bankTip':this.data.info.list[e.detail.value]
    })
  },
  async load(){
    let res=await wx.util.post("card/index");
    this.setData({
      info:res.data,
      'sub.bankTip':res.data.bank,
      'sub.card':res.data.card
    })
  },
  async done(){
    await wx.util.confirm("是否确认提交？","提交后将不可修改");
    await wx.util.post("card/add",this.data.sub,false);
    wx.util.toast('操作成功');
    await wx.util.sleep(500);
    wx.navigateBack();
  }
})